/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-07
 * Time: 12:01
 */
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
 class solution1{
    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //1：获取输入
            int n = in.nextInt() , q = in.nextInt();//长度为n的数组，q次查询
            int[] arr = new int[n+1];
            for(int i = 1 ; i <= n ; i++){
                arr[i] = in.nextInt();
            }

            //2：创建dp数组
            long[] dp = new long[n+1];
            for(int i = 1 ; i <= n ; i++){
                dp[i] = dp[i-1] + arr[i];
            }

            while(q > 0){
                int l = in.nextInt() , r = in.nextInt();
                System.out.println(dp[r]-dp[l-1]);
                q--;
            }


        }
    }
}

public class Test1 {
}
